﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using Xeml.Document.Contracts;
using Xeml.Document;

namespace Xid.Controls
{
    public partial class HirachicalViewFrm : KryptonForm
    {
        public IOntologyTerm SelectedTerm { get; private set; }

        public HirachicalViewFrm()
        {
            InitializeComponent();
        }

        public void Setup(IOntologyHandler ontology)
        {

            hirachicalViewCtrl1.Setup(ontology);
            hirachicalViewCtrl1.PropertyChanged += new PropertyChangedEventHandler(hirachicalViewCtrl1_PropertyChanged);
        }

        void hirachicalViewCtrl1_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            SelectedTerm = hirachicalViewCtrl1.SelectedTerm;
            if (SelectedTerm != null)
            {
                Term proto = SelectedTerm.Prototype;

                kryptonLabelTermId.Text = SelectedTerm.TermId;
                kryptonLabelTerm.Text = proto.Name;
                kryptonLabelNameSpace.Text = proto.NameSpace;
                kryptonLabelNsAlias.Text = proto.NameSpaceAlias;
                kryptonTextBoxDefinition.Text = SelectedTerm.Definition;
            }
            else
            {
                kryptonLabelTermId.Text = "---";
                kryptonLabelTerm.Text = "---";
                kryptonLabelNameSpace.Text = "---";
                kryptonLabelNsAlias.Text = "---";
                kryptonTextBoxDefinition.Text = "";
            }
        }
    }
}
